{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "yujDEgk2LDj6l9YTbZRdfmDn",
      "metadata": {
        "tags": [],
        "id": "yujDEgk2LDj6l9YTbZRdfmDn"
      },
      "source": [
        "Install the Vertex AI SDK"
      ]
    },
    {
      "cell_type": "code",
      "id": "jUYXCkLzW6u0BHTWbb4zUxM3",
      "metadata": {
        "tags": [],
        "id": "jUYXCkLzW6u0BHTWbb4zUxM3",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "executionInfo": {
          "status": "ok",
          "timestamp": 1705372110863,
          "user_tz": 480,
          "elapsed": 10348,
          "user": {
            "displayName": "",
            "userId": ""
          }
        },
        "outputId": "65e88738-0e92-4b01-a3c6-a89b64edf4c4"
      },
      "source": [
        "!pip install --upgrade google-cloud-aiplatform\n"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Requirement already satisfied: google-cloud-aiplatform in /root/.local/lib/python3.10/site-packages (1.39.0)\n",
            "Requirement already satisfied: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (2.11.1)\n",
            "Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (1.23.0)\n",
            "Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (3.20.3)\n",
            "Requirement already satisfied: packaging>=14.3 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (23.2)\n",
            "Requirement already satisfied: google-cloud-storage<3.0.0dev,>=1.32.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (2.8.0)\n",
            "Requirement already satisfied: google-cloud-bigquery<4.0.0dev,>=1.15.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (3.12.0)\n",
            "Requirement already satisfied: google-cloud-resource-manager<3.0.0dev,>=1.3.3 in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (1.11.0)\n",
            "Requirement already satisfied: shapely<3.0.0dev in /usr/local/lib/python3.10/dist-packages (from google-cloud-aiplatform) (2.0.2)\n",
            "Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (1.62.0)\n",
            "Requirement already satisfied: google-auth<3.0.dev0,>=2.14.1 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (2.17.3)\n",
            "Requirement already satisfied: requests<3.0.0.dev0,>=2.18.0 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (2.31.0)\n",
            "Requirement already satisfied: grpcio<2.0dev,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (1.51.3)\n",
            "Requirement already satisfied: grpcio-status<2.0.dev0,>=1.33.2 in /usr/local/lib/python3.10/dist-packages (from google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (1.48.2)\n",
            "Requirement already satisfied: google-cloud-core<3.0.0dev,>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-bigquery<4.0.0dev,>=1.15.0->google-cloud-aiplatform) (2.3.3)\n",
            "Requirement already satisfied: google-resumable-media<3.0dev,>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from google-cloud-bigquery<4.0.0dev,>=1.15.0->google-cloud-aiplatform) (2.7.0)\n",
            "Requirement already satisfied: python-dateutil<3.0dev,>=2.7.2 in /usr/local/lib/python3.10/dist-packages (from google-cloud-bigquery<4.0.0dev,>=1.15.0->google-cloud-aiplatform) (2.8.2)\n",
            "Requirement already satisfied: grpc-google-iam-v1<1.0.0dev,>=0.12.4 in /usr/local/lib/python3.10/dist-packages (from google-cloud-resource-manager<3.0.0dev,>=1.3.3->google-cloud-aiplatform) (0.13.0)\n",
            "Requirement already satisfied: numpy>=1.14 in /usr/local/lib/python3.10/dist-packages (from shapely<3.0.0dev->google-cloud-aiplatform) (1.23.5)\n",
            "Requirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (5.3.2)\n",
            "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (0.3.0)\n",
            "Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.10/dist-packages (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (1.16.0)\n",
            "Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (4.9)\n",
            "Requirement already satisfied: google-crc32c<2.0dev,>=1.0 in /usr/local/lib/python3.10/dist-packages (from google-resumable-media<3.0dev,>=0.6.0->google-cloud-bigquery<4.0.0dev,>=1.15.0->google-cloud-aiplatform) (1.5.0)\n",
            "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (3.3.2)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (3.6)\n",
            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (2.0.7)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (2023.11.17)\n",
            "Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3.0.dev0,>=2.14.1->google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,<3.0.0dev,>=1.32.0->google-cloud-aiplatform) (0.5.1)\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "id": "zpEWRrw3Icv8cQO3zearAqdt",
      "metadata": {
        "tags": [],
        "id": "zpEWRrw3Icv8cQO3zearAqdt"
      },
      "source": [
        "Use the following code to request a model response"
      ]
    },
    {
      "cell_type": "code",
      "id": "Hkwt1sAArIaLliYWfACOpLpO",
      "metadata": {
        "tags": [],
        "id": "Hkwt1sAArIaLliYWfACOpLpO",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "executionInfo": {
          "status": "ok",
          "timestamp": 1705372205882,
          "user_tz": 480,
          "elapsed": 21767,
          "user": {
            "displayName": "",
            "userId": ""
          }
        },
        "outputId": "20b4bcfb-2a98-4294-948a-29510038bbbb"
      },
      "source": [
        "\n",
        "import vertexai\n",
        "from vertexai.preview.generative_models import GenerativeModel, Part\n",
        "\n",
        "def generate():\n",
        "  model = GenerativeModel(\"gemini-pro\")\n",
        "  responses = model.generate_content(\n",
        "    \"\"\"What are the biggest challenges facing the healthcare industry?\n",
        "What is  Cybersecurity automation?\n",
        "What is Hybrid cloud computing?\"\"\",\n",
        "    generation_config={\n",
        "        \"max_output_tokens\": 2048,\n",
        "        \"temperature\": 0.9,\n",
        "        \"top_p\": 1\n",
        "    },\n",
        "  stream=True,\n",
        "  )\n",
        "\n",
        "  for response in responses:\n",
        "      print(response.text, end=\"\")\n",
        "\n",
        "\n",
        "generate()\n"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "**Biggest Challenges Facing the Healthcare Industry:**\n",
            "\n",
            "1. **Rising healthcare costs:** The cost of healthcare is rising faster than the rate of inflation, making it difficult for individuals and families to afford healthcare services.\n",
            "\n",
            "2. **Aging population:** The world's population is aging, which is leading to an increase in chronic diseases and healthcare needs. This is putting a strain on healthcare systems and resources.\n",
            "\n",
            "3. **Shortage of healthcare professionals:** There is a global shortage of healthcare professionals, including doctors, nurses, and other healthcare providers. This is making it difficult for people to access healthcare services in a timely manner.\n",
            "\n",
            "4. **Unequal access to healthcare:** Access to healthcare varies greatly around the world. In some countries, people have access to high-quality healthcare services, while in others, people have limited or no access to healthcare.\n",
            "\n",
            "5. **Advancements in technology:** The rapid pace of technological change is creating new opportunities for healthcare providers to deliver better care. However, it is also creating challenges, such as the need for healthcare providers to keep up with new technologies and the need to protect patient data from cyberattacks.\n",
            "\n",
            "6. **Drug resistance:** The increasing resistance of bacteria and other microorganisms to antibiotics and other drugs is a major public health threat. This is making it more difficult to treat infections and is leading to longer hospital stays and higher healthcare costs.\n",
            "\n",
            "**Cybersecurity Automation:**\n",
            "\n",
            "Cybersecurity automation is the use of software and tools to automate cybersecurity tasks. This includes tasks such as:\n",
            "\n",
            "* **Vulnerability assessment and management:** This involves identifying and patching vulnerabilities in software and systems.\n",
            "* **Intrusion detection and prevention:** This involves monitoring networks and systems for suspicious activity and taking action to prevent or stop attacks.\n",
            "* **Security information and event management (SIEM):** This involves collecting and analyzing security data from various sources to identify threats and trends.\n",
            "* **Incident response:** This involves responding to security incidents in a timely and effective manner.\n",
            "\n",
            "Cybersecurity automation can help organizations to improve their security posture, reduce the risk of cyberattacks, and improve their response to security incidents.\n",
            "\n",
            "**Hybrid Cloud Computing:**\n",
            "\n",
            "Hybrid cloud computing is a cloud computing model that combines on-premises and public cloud resources. This allows organizations to take advantage of the benefits of both private and public clouds, such as:\n",
            "\n",
            "* **Cost savings:** Hybrid cloud computing can help organizations to save money by using public cloud resources for less critical applications and data, while keeping more sensitive applications and data on-premises.\n",
            "* **Flexibility:** Hybrid cloud computing allows organizations to scale their IT resources up or down as needed, which can help them to meet changing business needs.\n",
            "* **Security:** Hybrid cloud computing can help organizations to improve their security by isolating sensitive applications and data on-premises, while still allowing them to take advantage of the security features of public clouds.\n",
            "\n",
            "Hybrid cloud computing is a good option for organizations that need the flexibility and scalability of the public cloud, but also need to keep some applications and data on-premises."
          ]
        }
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.10"
    },
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}